package yxy.game.sdk.test;

import com.alibaba.fastjson.JSONObject;
import yxy.apple.http.server.business.BusinessType;
import yxy.apple.logger.Logger;
import yxy.game.bean.LoginOtherParm;
import yxy.game.login.LoginModule;
import yxy.game.pm2.bean.cluster.ClusterBean;

@BusinessType(code = "LOGIN")
public class Login extends Sdk_test {
	static final Logger logger = Logger.create(Login.class);

	@Override
	public JSONObject handle(JSONObject request) throws Exception {
		String username = request.getString("username");
		String password = request.getString("password");
		String channel = name();
		String subchannel = name();
		String ip = request.getString("ip");
        int clusterId = ClusterBean.defaultClusterId;
        if (request.containsKey("clusterId")) {
			clusterId = request.getInteger("clusterId");
		}

        LoginOtherParm loginOtherParm = new LoginOtherParm();
        loginOtherParm.setClusterId(clusterId);

		return new LoginModule().login(username, password, channel, subchannel, ip, loginOtherParm);
	}

}
